
from pyecharts.charts import Bar
from pyecharts.faker import Faker
import pyecharts.options as opts

self.leftListWidget.clicked.connect(self.switchStackView)
self.chartsTabWidget.currentChanged.connect(self.switchCharts)
self.chartsTabWidget.currentChanged.connect(self.switchCharts)
self.chartsTabWidget.currentChanged.connect(self.switchCharts)

def switchStackView(self):
    print(self.leftListWidget.currentRow())
    currRow = self.leftListWidget.currentRow()
    if currRow == 1:
        self.rightStackedWidget.setCurrentWidget(self.cardTablePage)
    elif currRow == 2:
        self.rightStackedWidget.setCurrentWidget(self.goodsPage)
    elif currRow == 3:
        self.rightStackedWidget.setCurrentWidget(self.salesRecordPage)
    elif currRow == 4:
        self.rightStackedWidget.setCurrentWidget(self.chartsPage)
        self.switchCharts()


def switchCharts(self):
    print(self.chartsTabWidget.tabBar().currentIndex())
    currIndex = self.chartsTabWidget.tabBar().currentIndex()
    if currIndex == 0:
        c = (Bar().add_xaxis(Faker.days_attrs).add_yaxis(
            "商家A", Faker.days_values).set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom（slider-水平）"),
            datazoom_opts=opts.DataZoomOpts(),
        ))
        self.chartWebView1.setHtml(c.render_embed())
    elif currIndex == 1:
        c = (Bar().add_xaxis(Faker.days_attrs).add_yaxis(
            "商家A", Faker.days_values).set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom（slider-水平）"),
            datazoom_opts=opts.DataZoomOpts(),
        ))
        self.chartWebView2.setHtml(c.render_embed())
    elif currIndex == 2:
        c = (Bar().add_xaxis(Faker.days_attrs).add_yaxis(
            "商家A", Faker.days_values).set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom（slider-水平）"),
            datazoom_opts=opts.DataZoomOpts(),
        ))
        self.chartWebView3.setHtml(c.render_embed())

